<template>
  <d2-container>
    <div class="d2-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>房产审核</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-form :inline="true" class="SearchForm">
      <el-form-item label="房产名称">
        <el-input
          placeholder="请输入"
          type="text"
          v-model.trim="searchForm.Name"
        ></el-input>
      </el-form-item>
      <el-form-item label="房东姓名">
        <el-input
          placeholder="请输入"
          type="text"
          v-model.trim="searchForm.Name"
        ></el-input>
      </el-form-item>
      <el-form-item label="房东手机号">
        <el-input
          placeholder="请输入"
          type="text"
          v-model.trim="searchForm.Name"
        ></el-input>
      </el-form-item>
      <el-form-item label="地址">
        <el-input
          placeholder="请输入"
          type="text"
          v-model.trim="searchForm.Name"
        ></el-input>
      </el-form-item>
      <el-form-item label="详细地址">
        <el-input
          placeholder="请输入"
          type="text"
          v-model.trim="searchForm.Name"
        ></el-input>
      </el-form-item>
      <el-form-item label="房产类型">
        <el-select v-model="searchForm.region" placeholder="请选择">
          <el-option label="一" value="shanghai"></el-option>
          <el-option label="二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="房源经纪人名称">
        <el-input type="text" v-model.trim="searchForm.Name"></el-input>
      </el-form-item>
      <el-form-item label="关联园区名称">
        <el-input
          placeholder="请输入"
          type="text"
          v-model.trim="searchForm.Name"
        ></el-input>
      </el-form-item>
      <el-form-item label="房产状态">
        <el-select v-model="searchForm.region" placeholder="请选择">
          <el-option label="一" value="shanghai"></el-option>
          <el-option label="二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="上架状态">
        <el-select v-model="searchForm.region" placeholder="请选择">
          <el-option label="一" value="shanghai"></el-option>
          <el-option label="二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="提交时间">
        <el-input type="text" v-model.trim="searchForm.Name"></el-input>
      </el-form-item>
       <el-button type="primary" @click="search()" icon="el-icon-search"
        >查询</el-button
      >
      <el-button type="danger" icon="el-icon-refresh" @click="reset"
        >重置</el-button
      >
    </el-form>

    <el-table border :data="tableData.list">
      <el-table-column label="序号" align="center" prop="_id"></el-table-column>
      <el-table-column
        label="房产名称"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房东UID"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房东姓名"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房东手机号"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="地址"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="详情地址"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="面积"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房产类型"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房源经纪人名称"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房源经纪人联系方式"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="关联园区名称"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column
        label="房产状态"
        align="center"
        prop="title"
      ></el-table-column>
      <el-table-column label="添加时间" align="center" prop="create_time">
        <template slot-scope="scope">
          {{ $moment(scope.row.create_time).format("YYYY-MM-DD hh:mm:ss") }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
          <router-link :to="`/house/auditDetail/${scope.row._id}`">
            <el-button type="text">查看</el-button>
          </router-link>
          <el-button
            type="text"
            class="margin-left"
            @click="pass(scope.row.id)"
            >通过</el-button
          >
          <el-button
            type="text"
            class="margin-left"
            @click="reject(scope.row.id)"
            >驳回</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="search"
      @current-change="search"
      :current-page.sync="page"
      :page-sizes="[10, 25, 50, 100]"
      :page-size.sync="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.count"
    ></el-pagination>
  </d2-container>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      searchForm: {
        user_name: "",
      },
      tableData: {
        list: [{}],
        count: 0,
      },
      page: 1,
      pageSize: 10,
    };
  },
  methods: {
    search() {
      let params = {
        page: this.page,
        page_size: this.pageSize,
        ...this.searchForm,
      };

      this.$axios.post("/admin/getNoteList", params).then((result) => {
        if (result) {
          this.tableData = result;
        } else {
          this.$message.error(result.data.msg);
        }
      });
    },
    reset() {
      this.searchForm = {};
      this.search();
    },
    pass(id) {
      const _this = this;
      this.$confirm("确定通过改审核吗？", "确认通过", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "success",
        closeOnPressEscape: false,
        closeOnClickModal: false,
      }).then(() => {
        let params = {
          _id: id,
        };
        _this.$axios.post("/admin/deleteNote", params).then((res) => {
          if (res) {
            _this.$message({
              message: res.data.msg,
              type: "error",
            });
          } else {
            _this.$message({
              message: "删除成功",
              type: "success",
            });
            _this.search();
          }
        });
      });
    },
    reject(id) {
      const _this = this;
      this.$confirm("确定驳回该条审核吗？", "确认驳回", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        closeOnPressEscape: false,
        closeOnClickModal: false,
      }).then(() => {
        let params = {
          _id: id,
        };
        _this.$axios.post("/admin/deleteNote", params).then((res) => {
          if (res) {
            _this.$message({
              message: res.data.msg,
              type: "error",
            });
          } else {
            _this.$message({
              message: "删除成功",
              type: "success",
            });
            _this.search();
          }
        });
      });
    },
  },
  created() {
    // this.search();
  },
};
</script>

<style scoped lang="scss">
</style>
